<script setup>
import { defineComponent } from "vue";
defineComponent({
  name: "SupermapLegend",
});
const props = defineProps({
  legendData: {
    type: Array,
    default: []
  },
  legendTitle: {
    type: String,
    default: "高程",
  },
});
</script>
<template>
  <!-- 图例 -->
  <div class="legend">
    <div class="body">
      <div class="legend-item">
        <div class="left item item-title">
          <span>{{ legendTitle }}</span>
        </div>
        <div class="right item item-title">
          <span>颜色</span>
        </div>
      </div>
      <el-tooltip class="box-item" effect="dark"  placement="left" :content="item.detail" raw-content
        v-for="(item, index) in legendData" :key="index">
        <div class="legend-item content">
          <div class="left item">
            <span>{{ item.value }}</span>
          </div>
          <div class="right item">
            <div class="inner" :style="'background-color:' + item.style"></div>
          </div>
        </div>
      </el-tooltip>
    </div>
  </div>
</template>
<style lang="less" scoped>
.legend {
  position: absolute;
  width: 300px;
  bottom: 10px;
  left: 10px;
  z-index: 400;
}

.body {
  color: #f2f2f2;
  text-align: center;
  padding: 5px 10px;
}

.legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 5px 0;
  padding: 5px 0;
  transition: all .3s;
  &:hover {
    background-color: rgba(63, 81, 181, 0.5);
    &.content>.item.left {
      color: #fff;
      font-weight: bolder;
    }
    &.content>.item.right {
      transform: scale(1.1);
    }
  }
}

.legend-item>.item {
  width: 50%;
  height: 20px;
  line-height: 20px;
}

.legend-item>.item.item-title {
  font-size: 16px;
  color: var(--base-font-color, #fff);
  text-shadow: 0 0 3px var(--base-light-color2, #45c3ff);
}

.legend-item>.item.left {
  text-align: left;
  padding-left: 20px;
}

.legend-item.content>.item.right {
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all .3s;
}

.legend-item.content>.item.right>.inner {
  height: 14px;
  width: 90%;
}
</style>
